package com.sky.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单明细
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderDetail implements Serializable {

    private static final long serialVersionUID = 1L;


    //id
    private Long id;

    //名称
    private String name;

    //图片
    private String image;

    //订单id
    private Long orderId;

    //菜品id
    private Long dishId;

    //套餐id
    private Long setmealId;

    //口味
    private String dishFlavor;

    //数量
    private Integer number;

    //金额
    private BigDecimal amount;


    /**
     * 静态方法 创建本类
     */
    public static OrderDetail init(String name, String image, Long orderId, Long dishId, Long setmealId, String dishFlavor, Integer number, BigDecimal amount){
        OrderDetail orderDetail = new OrderDetail();
        if(StringUtils.hasLength(name)){
            orderDetail.setName(name);
        }
        if(StringUtils.hasLength(image)){
            orderDetail.setImage(image);
        }
        if(null != orderId){
            orderDetail.setOrderId(orderId);
        }
        if(null != dishId){
            orderDetail.setDishId(dishId);
        }
        if(null != setmealId){
            orderDetail.setSetmealId(setmealId);
        }
        if(StringUtils.hasLength(dishFlavor)){
            orderDetail.setDishFlavor(dishFlavor);
        }
        if(null != number){
            orderDetail.setNumber(number);
        }
        if(null != amount){
            orderDetail.setAmount(amount);
        }

        return orderDetail;
    }


}
